//
//  ZCBaseController.swift
//  weibo
//
//  Created by 张城 on 16/7/19.
//  Copyright © 2016年 张城. All rights reserved.
//

import UIKit

class ZCBaseController: UIViewController {
    
    var islogon: Bool = ZCuserAccountViewModel.sharedTools.isLogin
    
    var bgview: ZCVisiterView?
    
    override func loadView() {
        super.loadView()
        islogon ? view = tableView : setupVisit()
    }
    
    func setupVisit()  {
        bgview = ZCVisiterView()
        bgview?.callback = {[weak self] in
            self?.loginButClick()
        }
        view = bgview
        
        setupNav()
    }
    
    func setupNav()  {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", imgName: nil, target: self, action: #selector(ZCBaseController.loginButClick))
        navigationItem.rightBarButtonItem = ZCBarButtonItem(title: "注册", imgName: nil, target: self, action: #selector(ZCBaseController.loginButClick))
        
    }
    
    @objc private func loginButClick() {
        presentViewController(UINavigationController(rootViewController: ZCOAuthController()), animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    lazy var tableView: UITableView = UITableView()
}
